//
//  OffLineView.m
//  xpkc
//
//  Created by TopSageOSX on 14-8-25.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "OffLineView.h"

@implementation OffLineView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self creatOffLineView];
    }
    return self;
}
/**
 *  创建离线视图
 */
- (void)creatOffLineView{
    self.backgroundColor = [UIColor whiteColor];
    NSArray *array = @[@"已完成",@"下载中"];
    //创建控件
    
    self.segmentController = [[UISegmentedControl alloc]initWithItems:array];
    self.noteLabel = [[UILabel alloc]init];
    //设定位置
    CGRect segmengt_frame;
    CGRect tableview_frame;//两个下载视图在一个位置上
    CGRect note_frame;
    if (isPad) {
        //适配
        segmengt_frame = RECT(SCREEN_WIDTH/5, 10, SCREEN_WIDTH*3/5, 40);
        tableview_frame = RECT(0, 60, SCREEN_WIDTH, SCREEN_HEIGHT-60-64);
        note_frame = RECT(0, SCREEN_HEIGHT/4, SCREEN_WIDTH, 50);
    }else{
        segmengt_frame = RECT(SCREEN_WIDTH/5, 10, SCREEN_WIDTH*3/5, 30);
        tableview_frame = RECT(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT-50-64);
        note_frame = RECT(0, SCREEN_HEIGHT/4, SCREEN_WIDTH, 50);
    }
    self.downloadedTableView.frame = tableview_frame;
    self.downloadingTableView.frame = tableview_frame;
    self.segmentController.frame = segmengt_frame;
    self.noteLabel.frame = note_frame;
    self.downloadedTableView = [[UITableView alloc]initWithFrame:tableview_frame style:UITableViewStylePlain];
    self.downloadingTableView = [[UITableView alloc]initWithFrame:tableview_frame style:UITableViewStylePlain];
    self.downloadedTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.downloadingTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //详细信息
    self.segmentController.tintColor = [UIColor orangeColor];
    ;
    self.segmentController.backgroundColor = [UIColor whiteColor];
    self.noteLabel.font = FONT_SYS_NORMAL;
    self.noteLabel.textColor = [UIColor lightGrayColor];
    self.noteLabel.textAlignment = NSTextAlignmentCenter;
    self.downloadingTableView.hidden = YES;
    self.downloadedTableView.hidden = YES;
    //添加视图
    [self addSubview:self.noteLabel];//最底层，方便覆盖
    [self addSubview:self.downloadedTableView];
    [self addSubview:self.downloadingTableView];
    [self addSubview:self.segmentController];
    //视图上方黄色线
    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, self.downloadedTableView.frame.origin.y-2, SCREEN_WIDTH, 2)];
    label.backgroundColor=OrangeColor;
    [self addSubview:label];
    
}


@end
